<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
    <script>
		function object(o) {
			function F () {};
			F.prototype = o;
			return new F();
		}
		function inheritPrototype (subType, superType) {
			var prototype = object(superType.prototype);
			prototype.constructor = subType;
			subType.prototype = prototype;
		};
		function SuperType (name) {
			this.name = name;
			this.colors = ['red','blue']
		};

		SuperType.prototype.sayName = function () {
			console.log(this.name);
		};

		function SubType (name,age) {
			SuperType.call(this,name);
			this.age = age;
		}

		inheritPrototype(SubType,SuperType)

		SubType.prototype.sayAge = function () {
			console.log(this.age);
		};

		var sub = new SubType('xiao', '22');
		var sup = new SuperType('bai', '2')
		sub.sayName(); // xiao
		sub.sayAge(); // 22
		sub.colors.push('black');
		console.log(sub.colors); //["red", "blue", "black"]
		console.log(sup.colors); // ["red", "blue"]
    </script>
</body>
</html>
